package com.mms.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.mms.entity.Dept;
import com.mms.service.DeptServiceImpl;
import com.mms.util.JSONUtils;


@WebServlet("/findDept")
public class SelectDeptByIdController extends HttpServlet{
		@Override
			protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
				// TODO Auto-generated method stub
				req.setCharacterEncoding("UTF-8");
				String id=req.getParameter("id");
				int idint=Integer.valueOf(id);
				DeptServiceImpl newdepDeptServiceImpl=new DeptServiceImpl();
				Dept dept=newdepDeptServiceImpl.findDept(idint);
				
				
				String result=JSONUtils.toJSONString(dept);
				resp.setContentType("application/jason;charset=UTF-8");
				resp.getWriter().write(result);
			}
}
